/*
 * Utils.h
 *
 *  Created on: 18 Jun 2011
 *      Author: allan
 */

#ifndef UTILS_H_
#define UTILS_H_

// C++ includes
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

//==================================================//
// Typedefs
//==================================================//
typedef unsigned
uint;

typedef uint
Index;

struct ReactionInfo
{
	/// The formula of the reactant in the reaction
	string reactant;
	
	/// The formulas of the products in the reaction 
	vector<string> products;
	
	/// The stoichiometries of the products in the reaction     
	vector<double> stoichiometries;
	
	/// The equilibrium constants of the reaction over a set of temperature points
	vector<double> logKi;
	
	/// The temperature points where the equilibrium constants are interpolated       
	vector<double> Ti;
};

struct SpeciesInfo
{
	string formula;
	string name;
	double molecularWeight;
	double volumetricWeigth;
	double radius;
	vector<string> tags;

	SpeciesInfo() : molecularWeight(0), volumetricWeigth(0), radius(0) {}

	bool 
	HasTag(const string& tag) const { return std::find(tags.begin(), tags.end(), tag) != tags.end(); }
	
	bool 
	HasAnyTag(const vector<string>& tags) const { for(uint i = 0; i < tags.size(); ++i) if(HasTag(tags[i])) return true; return false; }
};

//==================================================//
// Functions
//==================================================//
const double 
ElectricalCharge(string speciesName);

const vector<string>
SplitLineAndClean(const string& line, const string& tokens);

const vector<double> 
Range(double init, double end, double step);

//==================================================//
// Overloaded Operators
//==================================================//
ostream& operator<<(ostream& out, const vector<string>& vec);
ostream& operator<<(ostream& out, const vector<double>& vec);
ostream& operator<<(ostream& out, const vector<Index>&  vec);

#endif /* UTILS_H_ */
